Skip to content

Client refactor #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 14, 2019
Merged

Conversation

0bsearch
Copy link
Contributor

@0bsearch 0bsearch commented Jun 4, 2018

Fixes

Checklist

  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the [Contribution Guide] and my PR follows them.
  • I updated my branch with the master branch.
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation about the functionality in the appropriate .md file
  • I have added in line documentation to the code I modified

Short description of what this PR does:

Better signatures for client; minor refactoring

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Jun 4, 2018
@SendGridDX
Copy link

SendGridDX commented Jun 4, 2018

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Jun 4, 2018

Codecov Report

Merging #88 into master will increase coverage by 1.72%.
The diff coverage is 79.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #88      +/-   ##
==========================================
+ Coverage   91.46%   93.19%   +1.72%     
==========================================
  Files           6        6              
  Lines         293      294       +1     
==========================================
+ Hits          268      274       +6     
+ Misses         25       20       -5
Impacted Files Coverage Δ
tests/test_unit.py 99.26% <100%> (+0.06%) ⬆️
python_http_client/client.py 80.64% <50%> (+2.97%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa72b74...8812835. Read the comment docs.

@0bsearch 0bsearch force-pushed the client_refactor branch 2 times, most recently from 4c28722 to f656758 Compare June 4, 2018 18:05
@thinkingserious
Copy link
Contributor

Thank you @3lnc! I've added this to our backlog for a code review.

@thinkingserious thinkingserious added the difficulty: medium fix is medium in difficulty label Sep 28, 2018
@@ -62,6 +63,9 @@ def to_dict(self):
class Client(object):
"""Quickly and easily access any REST or REST-like API."""

# These are the supported HTTP verbs
methods = set(('delete', 'get', 'patch', 'post', 'put'))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set literal instead?

methods = {'delete', 'get', 'patch', 'post', 'put'}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At time this PR was created, http client claimed support for 2.6

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3lnc

Since that doesn't seem to be the case now... set literal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -84,7 +90,7 @@ def test__init__(self):
self.assertEqual(default_client.host, self.host)
self.assertEqual(default_client.request_headers, {})
self.assertIs(default_client.timeout, None)
methods = ['delete', 'get', 'patch', 'post', 'put']
methods = set(('delete', 'get', 'patch', 'post', 'put'))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set literal?

methods = {'delete', 'get', 'patch', 'post', 'put'}

@@ -97,7 +103,7 @@ def test__init__(self):
timeout=10)
self.assertEqual(client.host, self.host)
self.assertEqual(client.request_headers, request_headers)
methods = ['delete', 'get', 'patch', 'post', 'put']
methods = set(('delete', 'get', 'patch', 'post', 'put'))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set literal?

methods = {'delete', 'get', 'patch', 'post', 'put'}

self.client._update_headers({'X-test': 'Test'})
self.client.get()
request = maker.call_args[0][1]
self.assertTrue('X-test' in request.headers)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Available since 3.1, client provides support for 2.7 (2.6 previously)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@misterdorm
Copy link
Contributor

@3lnc Please address conflicts and code coverage failures. Thanks!

@misterdorm misterdorm added status: waiting for feedback waiting for feedback from the submitter and removed status: code review request requesting a community code review or review from Twilio labels Oct 31, 2018
@thinkingserious
Copy link
Contributor

Hi @3lnc,

When you get a moment to make the updates I'd love to merge this before we release v4 of the sendgrid-python library which will depend on this library.

Thanks!

With Best Regards,

Elmer

@thinkingserious thinkingserious added the type: community enhancement feature request not on Twilio's roadmap label Nov 14, 2018
request.add_header('Content-Type', 'application/json')
request = urllib.Request(
self._build_url(query_params),
headers=self.request_headers,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes an issue I am having when adding headers... request.add_header(key, value) capitalizes the header which some APIs don't seem to want. :-\

@thinkingserious thinkingserious merged commit 36b241f into sendgrid:master Jun 14, 2019
@thinkingserious
Copy link
Contributor

Hello @3lnc,

Thanks again for the PR!

We appreciate your contribution and look forward to continued collaboration. Thanks!

Team SendGrid DX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: waiting for feedback waiting for feedback from the submitter type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants